/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package univalle.eisc.pais.ai.searcheslab.logic;

import java.io.File;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import univalle.eisc.pais.ai.searcheslab.model.Config;
import univalle.eisc.pais.ai.searcheslab.model.Route;
import univalle.eisc.pais.ai.searcheslab.model.Stage;
import univalle.eisc.pais.ai.searcheslab.view.MainWindowView;
import univalle.eisc.pais.ai.searcheslab.view.SceneView;

/**
 *
 *
 * @author victor
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        if (args.length == 0) {
            java.awt.EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    new MainWindowView().setVisible(true);
                }
            });
        } else {
            int algorithm = Integer.parseInt(args[0]);
            String file = args[1];
            test(algorithm, file);
        }
    }

    static void test(int algorithm, String file) {
        try {
            Seeker seeker = new Seeker();
            Route route = null;
            Config config = new Config();
            config.loadConfig(new File(file));
            Stage stage = new Stage(config);

            switch (algorithm) {
                case 0:
                    route = seeker.breadth(stage);
                    break;
                case 1:
                    route = seeker.uniformCost(stage);
                    break;
                case 2:
                    route = seeker.depth(stage);
                    break;
                case 3:
                    route = seeker.greedy(stage);
                    break;
                case 4:
                    route = seeker.aStar(stage);
                    break;
                default:
                    ;
            }
        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
